<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-md-6">
        <h2>分类管理</h2>
        <ol class="breadcrumb">
            <li>
                <a href="{:U('admin/Index/index')}">主页</a>
            </li>
            <li class="active">
                <strong>分类管理</strong>
            </li>
        </ol>
    </div>
    <div class="col-md-6">
        <h2><a href="{:U('admin/catalog/add')}" class="btn btn-info pull-right">添加分类</a></h2>
    </div>
</div>
<div class="wrapper wrapper-content">
  	<div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>分类管理</h5>
        </div>
        <div class="ibox-content">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>分类名称</th>
                    <th style="text-align:center">操作</th>
                </tr>
                </thead>
                <tbody>
				<volist name="level1" id="l1">
					<tr class="level1">
	                    <td>{$l1.id}</td>
	                    <td class="name">{$l1.name}</td>
	                    <td style="text-align:center">
	                    	<a href="{:U('admin/catalog/edit/id')}/{$l1.id}" class="btn btn-primary btn-sm">编辑</a>
	                    	<a href="{:U('admin/catalog/del/id')}/{$l1.id}" class="btn btn-danger btn-sm delete">删除</a>
	                    </td>
	                </tr>
                    <?php $level2=M('product_catalog')->where('parent_id='.$l1['id'])->select();?>
                    <volist name="level2" id="l2">
                         <tr class="level2 parent_level{$l1.id}" id="{$l2.id}">
                           <td>{$l2.id}</td>
                            <td class="name">└───{$l2.name}</td>
                            <td style="text-align:center">
                                <a href="{:U('admin/catalog/edit/id')}/{$l2.id}" class="btn btn-primary btn-sm">编辑</a>
                                <a href="{:U('admin/catalog/del/id')}/{$l2.id}" class="btn btn-danger btn-sm delete">删除</a>
                            </td> 
                        </tr>
                        <?php $level3=M('product_catalog')->where('parent_id='.$l2['id'])->select();?>
                        <volist name="level3" id="l3" >
                             <tr class="level3 parent_level{$l2.id}">
                               <td>{$l3.id}</td>
                                <td>└───┴───{$l3.name}</td>
                                <td style="text-align:center">
                                    <a href="{:U('admin/catalog/edit/id')}/{$l3.id}" class="btn btn-primary btn-sm">编辑</a>
                                    <a href="{:U('admin/catalog/del/id')}/{$l3.id}" class="btn btn-danger btn-sm  delete">删除</a>
                                </td> 
                            </tr>
                        </volist>
                    </volist>
				</volist>
                </tbody>
            </table>
        </div>
    </div>
</div>
<style type="text/css">
    tr.level1{
        background:#eee;
    }
    tr.level2{
        background:#f8f8f8;
        cursor: pointer;
    }
    tr.level3{
       display:none;
    }
</style>
<script type="text/javascript">
    $(function(){
        
        $('.level2 td.name').click(function(){
            var id=$(this).parents('tr').attr('id');
            var cls='.parent_level'+id;
            $(cls).toggle(1000);
        });
    })
</script>

        